package com.baidu.ai.aip.faceDatabase;

import com.baidu.ai.aip.bean.FaceAddBean;
import com.baidu.ai.aip.bean.GroupGetlistBean;
import com.baidu.ai.aip.bean.JsonBean;
import com.baidu.ai.aip.bean.UserListBean;
import com.baidu.ai.aip.utils.Base64Util;
import com.baidu.ai.aip.utils.GsonUtils;

import java.io.IOException;
import java.util.List;

/**
 * 所有返回值均为json参数 未封装
 */
public class FaceDatabaseServiceImpl  {
    public JsonBean add(String imgUrl, String groupId, String userId, String userInfo) throws IOException {
        String img_Base64 = Base64Util.encode(imgUrl);
        String json = FaceAdd.add(img_Base64, groupId, userId, userInfo);
        return GsonUtils.fromJson(json, FaceAddBean.class);
    }

    public String update(String imgUrl, String groupId, String userId, String userInfo) throws IOException {
        String img_Base64 = Base64Util.encode(imgUrl);
        FaceAdd.add(img_Base64, groupId, userId, userInfo);
        return null;
    }

    public String userDelete(String groupId, String userId) throws Exception {
        UserDelete.userDelete(groupId, userId);
        return null;
    }

    public String userGet(String groupId, String userId) {
        /**TODO
         * 数据待封装 暂未完成
         */
        UserGet.userGet(groupId,userId);
        return null;
    }

    public String groupAdd(String groupId) {
        GroupAdd.groupAdd(groupId);
        return null;
    }

    public String groupDelete(String groupId) {
        GroupDelete.groupDelete(groupId);
        return null;
    }

    public String getUsers(String groupId) {
        String json = GroupGetusers.groupGetusers(groupId);
        System.out.println(json);
        return json;
    }

     public GroupGetlistBean groupGetlist() {
        GroupGetlist.groupGetlist();
        GroupGetlistBean groupListBean = GsonUtils.fromJson(GroupGetlist.groupGetlist(), GroupGetlistBean.class);
        return groupListBean;
    }

}
